package com.jic.market.controller.manage;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.request.manager.presell.*;
import com.jic.market.response.manager.presell.PresellGoodsPageQueryResponse;
import com.jic.market.service.PromotionPresellProductService;
import com.jic.market.service.PromotionPresellService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;

/**
 * @author yinhaijun
 * @date:
 */
@Api(tags = {"其他类-预售"})
@RestController
@RequestMapping("/presell")
public class PresellManageController implements Serializable {

    @Autowired
    private PromotionPresellService promotionPresellService;
    @Autowired
    private PromotionPresellProductService promotionPresellProductService;

    @ApiOperation(value = "复制")
    @PostMapping("copy")
    public RestResult<Long> copy(@RequestBody PromotionPresellCopyRequest request) {
        return promotionPresellService.copy(request);
    }

    @ApiOperation(value = "保存为模板")
    @PostMapping("saveTemplate")
    public RestResult<Long> saveTemplate(@RequestBody PromotionPresellSaveTemplateRequest request) {
        return promotionPresellService.saveTemplate(request);
    }

    @ApiOperation(value = "商品是否为空")
    @PostMapping("/productIsNull")
    public RestResult<Boolean> productIsNull(@RequestBody PresellProductIsNullRequest request) {
        return promotionPresellProductService.merchantAndStoreIsNull(request);
    }

    @ApiOperation(value = "商品Sku统计")
    @PostMapping("/skuCount")
    public RestResult<Long> skuCount(@RequestBody PresellProductIsNullRequest request) {
        return promotionPresellProductService.skuCount(request);
    }

    @ApiOperation(value = "批量添加商品")
    @PostMapping("product/addBatch")
    public RestResult<Long> addBatch(@RequestBody PresellProductAddBatchRequest request) {
        return promotionPresellProductService.addBatch(request);
    }

    @ApiOperation(value = "添加全部商品")
    @PostMapping("product/addBatchAll")
    public RestResult<Long> addBatchAll(@RequestBody PresellProductAddBatchAllRequest request) {
        return promotionPresellProductService.addBatchAll(request);
    }

//    @ApiOperation(value = "分页查询预售商品")
//    @PostMapping("product/pageQuery")
//    public RestResult<PageResult<PromotionPresellProduct>> pageQuery(@RequestBody PresellProductPageQueryRequest request) {
//        return promotionPresellProductService.pageQuery(request);
//    }

    @ApiOperation(value = "分页查询预售商品新")
    @PostMapping("product/pageQueryNew")
    public RestResult<PageResult<PresellGoodsPageQueryResponse>> queryManagerPage(@RequestBody PresellGoodsPageQueryRequest request) {
        return promotionPresellProductService.pageQueryNewNew(request);
    }

    @ApiOperation(value = "批量删除预售商品")
    @PostMapping("product/delBatch")
    public RestResult<Long> delBatch(@RequestBody PresellProductDeleteRequest request) {
        return promotionPresellProductService.delBatch(request);
    }

    @ApiOperation(value = "更新预售商品")
    @PostMapping("product/update")
    public RestResult<Long> update(@RequestBody PresellProductUpdateRequest request) {
        return promotionPresellProductService.update(request);
    }

    @ApiOperation(value = "下载商品模板")
    @GetMapping(value = "product/downloadTemplate")
    public void downloadTemplate(HttpServletResponse response) throws IOException {

    }


}
